<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.global.js"></script>
</head>

<body>
    <div id="app">
        <my-component class="baz boo"></my-component>

        <hr>

        <my-component :class="{ active: isActive }"></my-component>

        <hr>

        <my-component class="baz"></my-component>

        <hr>
        <your-component class="yoursister"></your-component>
    </div>

    <script>

        const app = Vue.createApp({
            data() {
                return {
                    isActive: true
                }
            }
        })

        /* 定义全局组件 */
        app.component('my-component', {
            template: `<p class="foo bar">
                Hi!
                <span>令爱</span>
            </p>`
        })

        app.component('your-component', {
            template: `
                <span>This is a child component</span>
                <p :class="$attrs.class">Hi!</p>
            `
        })

        app.mount("#app")
    </script>
</body>

</html>